|
Class: InstanceCollection
|
Manages a collection of instances of a modell class that is provided in the constructor.
The goodies are
- returns fully functional instances cloned from the modell class
- instances can be deleted without risking the 'next' function to malfunction( as it is with DocumentCollections)
- automates and simplifies the search to a great extend.
- allows to sort arrays.
-
Version:
-
2.0.0, 28.MAR.2000
-
History:
-
| 28.MAR.2000 | ESc | Reworked for docu standards
|
|
Property Summary
|
Public
Property
Get Count As Variant |
Public
Property
Get IsSorted As Variant |
Public
Property
Get Query As Variant |
|
Method Summary
|
Function GetFirstInstance () As Variant |
Function GetNextInstance () As Variant |
Function GetNthInstance (N As Integer) As Variant |
Sub LookUp (Database As Variant, View As Variant, Key As String) |
Sub New (id As String, ModelObject As Variant) |
Sub Search (Database As Variant, QueryObject As Variant) |
Sub Sort () |
Public Property Get Query AsVariant
Gives the query used to select the elements for the collection. In case of a lookup, an
artificial query including the viewname and key is created like "lookup 'myview' by 'mykey'"
-
Returns:
-
| Variant | which is a text with the query.
|
Public Property Get Count AsVariant
Counts the number of elements in the collection. The result is 0 if the collection does
not have elements.
-
Returns:
-
| Variant | Number of elements in the collection
|
Public Property Get IsSorted AsVariant
provides an indicator if the collection is sorted. The collection may be sorted if the view is
sorted or if the sort has explicitely created a sort order.
-
Returns:
-
| Variant | which is true or false
|
-
See also:
-
New
Public Sub New(id As String,ModelObject As Variant)
The constructor initializes the collection and making the MODELINSTANCE known. This model
provides the capability to clone the instances managed in this collection . It also sets the ID,
which will become the suggested name, that is made unique by a number.
After initialization the collection does not contain any elements. You first ned to search or lookup
elements.
-
Parameters:
-
| ID | String | the name of the instances.
|
| ModelObject | Variant | that is the MODELINSTANC managed by that collection
|
-
See also:
-
GetFirstInstance
Public Function GetFirstInstance As Variant
The first instance of the collection is provided or NOTHING if no elements is found.
-
Returns:
-
| Variant | which a clone of the MODELINSTANCE
|
GetNextInstance
Public Function GetNextInstance As Variant
The next instance of the collection is provided. It progresses in a random order and returns
NOTHING if no further elements are found.
-
Returns:
-
| Variant | which a clone of the MODELINSTANCE
|
GetNthInstance
Public Function GetNthInstance(N As Integer) As Variant
Returns the Nth instance of the collection. This requires the collection to be sorted.
If the collection is not sorted it will always return NOTHING.
-
Parameters:
-
| index | Integer | pointing to the instance to be retrieved
|
-
Returns:
-
| Variant | which a clone of the MODELINSTANCE
|
-
See also:
-
Search
Public Sub Search(Database As Variant,QueryObject As Variant)
Fills the collection with the instances found by the search.
- It the QueryObject is a string,
we assume this to be the query and the instance to be able to work on the resulting documents.
- If the Query object is a real object, then we expect the Modelobject to create a query from that.
Example:
Lets have a collection of keyword references that point to to a keyword definition. Lets assume we want to
process the collection of keyword references for update. In this case the model would be the keyword reference
and the queryObject would be the keyword definition. In this case the search would ask the query
to provide a proper query that finds all those instances refered to by the defining queryObject.
-
Parameters:
-
| Database | Variant | a NOTESDATABASE or parent database is used
|
| QueryObject | Variant | QueryObject as ANYINSTANCE or String
|
LookUp
Public Sub LookUp(Database As Variant,View As Variant,Key As String)
Fills the collection with the instances in the view.
CAUTION:
Make sure that the key finds the right documents that the instance can work upon!
-
Parameters:
-
| Database | Variant | usually a NOTESDATABASE or parent database is used
|
| View | Variant | a NOTESVIEW, or a Viewname in the database
|
| Key | String | the Key to be looked for.
|
Sort
Public Sub Sort
Sorts the collection. The sortkey isprovided by the each instance by the 'getSortstring' method.
This method is required for sorting.
CAUTION:
this may be extreemly time consuming for larger collections!
-
See also:
-
| Top | LotusScript Doc |
| © Lotus Professional Services |
| generated on : 05-Apr-01 10:01:44 AM |